<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>注册</title>
    <link href="css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
</head>
<body style="background-image: url(./images/register_back2.jfif); background-size: auto; height: 100%;">
	<!-- 顶部导航 -->
	<header class="mui-bar mui-bar-nav header">
		<span class="mui-icon mui-icon-back" onclick="back()"></span>
		<h1 class="mui-title GTM">注册</h1>
	</header>
	<div id="">
		<!-- 主体内容 -->
		<!-- <img src="images/register1.jfif" style="width: 100%;height: 8%;"> -->
		<form style="margin-top: 160px; border: 0;">
			<div style="text-align: center;">
				<input style="height: 40px; width: 70%; margin: 0 auto; background-color: #f5f5f5; border-radius: 20px; border: 0;" type="text" placeholder="邮箱/手机号" id="account">
			</div>
			<div style="text-align: center; margin-top: 15px;">
				<input style="height: 40px; width: 70%; margin: 0 auto; background-color: #f5f5f5; border-radius: 20px; border: 0;" type="password" class="mui-input-password" placeholder="密码" id="password">
			</div>
			<div style="text-align: center; margin-top: 15px;">
				<input style="height: 40px; width: 70%; margin: 0 auto; background-color: #f5f5f5; border-radius: 20px; border: 0;" type="password" class="mui-input-password" placeholder="确认密码" id="veri_password">
			</div>
			<div style="text-align: center; margin-top: 15px;">
				<input style="height: 40px; width: 70%; margin: 0 auto; background-color: #f5f5f5; border-radius: 20px; border: 0;" type="text" placeholder="姓名" id="name">
			</div>
			<div style="text-align: center; margin-top: 15px;">
				<input style="height: 40px; width: 70%; margin: 0 auto; background-color: #f5f5f5; border-radius: 20px; border: 0;" type="text" placeholder="公司/单位" id="company">
			</div>
			<div style="text-align: center; margin-top: 15px;">
				<input style="height: 40px; width: 70%; margin: 0 auto; background-color: #f5f5f5; border-radius: 20px; border: 0;" type="text" placeholder="所属部门" id="part">
			</div>
			<div style="text-align: center; margin-top: 15px;">
				<input style="height: 40px; width: 70%; margin: 0 auto; background-color: #f5f5f5; border-radius: 20px; border: 0;" type="text" placeholder="职位职称" id="title">
			</div>
		</form>
		<div class="mui-button-row" style="margin-top: 25px; border: 0rem;">
			<button type="button" class="mui-btn mui-btn-primary" id="primary" onclick="register()" style="width:68%;">注册</button>
		</div>
		<div id="" style="text-align: center; margin-top: 20px;">
			<hr >
			<div class="mui-input-row mui-checkbox mui-left">
				<input name="checkbox1" value="Item 1" type="checkbox" checked style="margin-left: 14%;">
				<label style="color: white;">已阅读并同意《用户协议》</label>
			</div>
		</div>
	</div>
</body>
<script src="js/mui.min.js"></script>
<script type="text/javascript" charset="utf-8">
      	mui.init();
		mui.plusReady(
			document.getElementById('exit').addEventListener('tap', function (){
				plus.webview.open("login.html")
			})
		)
		function back(){
			mui.openWindow({
			  url:'./login.html',					
			  id:'login.html'			
			  });
		}
		function register(){
			var Account = document.getElementById("account").value
			var Password = document.getElementById("password").value
			var Veri_password = document.getElementById("veri_password").value
			var Name = document.getElementById("name").value
			var Company = document.getElementById("company").value
			var Part = document.getElementById("part").value
			var Title = document.getElementById("title").value
			
			if (Password != Veri_password){
				alert("两次输入的密码不一致，请重新输入")
				return false
			}
			
			mui.ajax('http://localhost:8080/user/register',{
				data:{
					account: Account,
					password: Password,
					name: Name,
					company: Company,
					part: Part,
					title: Title
				},
				dataType:'json',//服务器返回json格式数据
				type:'post',//HTTP请求类型
				timeout:10000,//超时时间设置为10秒；
				headers:{'Content-Type':'application/json'},
				success:function(data){
					if (data == "success"){
						alert("注册成功，请返回登录!")
						mui.openWindow({
						  url:'./login.html',					
						  id:'login.html'			
						  });
					}
					else{
						alert("注册失败 ，请重新注册")
					}
				},
				error:function(xhr,type,errorThrown){
					alert("注册失败！重新尝试")
				}
			});
		}
</script>
<script type="text/javascript">
</script>
</html>